4 extension CVImageBuffer {
6 var cgImage: CGImage? {
7 let ciImage = CIImage(cvImageBuffer: self)
8 let context = CIContext()
9 return context.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: CVPixelBufferGetWidth(self), height: CVPixelBufferGetHeight(self)))